<template>
  <div class="login-container w-full h-full flex_aic_jcc">
    <div class="login-right">
      <div class="right_bg flex_fdc_aic">
        <div class="login_title mb20 nowrap">
          欢迎登录<span class="fs-14 ml4 mt4">哈萨克餐饮</span>
        </div>
        <el-form
          ref="ruleFormRef"
          style="max-width: 600px"
          :model="formData"
          :rules="rules"
          label-width="auto"
          class="demo-ruleForm"
        >
          <el-form-item prop="username" class="mt20">
            <el-input
              v-model="formData.username"
              class="login_input"
              style="width: 340px"
              :placeholder="$t('login.请输入用户名')"
            >
              <template #prefix>
                <img src="@/assets/images/login/user.png" alt="" />
              </template>
            </el-input>
          </el-form-item>
          <el-form-item prop="password" class="mt20">
            <el-input
              v-model="formData.password"
              type="password"
              class="login_input"
              style="width: 340px"
              :placeholder="$t('login.请输入密码')"
            >
              <template #prefix>
                <img src="@/assets/images/login/psw.png" alt="" />
              </template>
            </el-input>
          </el-form-item>
          <el-form-item prop="code" class="mt20">
            <div class="flex_aic">
              <el-input
                v-model="formData.code"
                type="password"
                class="login_input flex1"
                style="width: 340px"
                :placeholder="$t('login.请输入验证码')"
              >
                <template #prefix>
                  <img src="@/assets/images/login/code.png" alt="" />
                </template>
                <template #append>
                  <img
                    class="login_code"
                    src="@/assets/images/login/code.png"
                    alt=""
                  />
                </template>
              </el-input>
            </div>
          </el-form-item>
          <el-button
            type="primary"
            class="login_btn mt40"
            style="width: 340px; height: 48px"
            @click="handleLogin"
            ><span class="fs-20 font-bold">{{
              $t("login.立即登录")
            }}</span></el-button
          >
        </el-form>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from "vue";
import { useRouter } from "vue-router";

const router = useRouter();
const ruleFormRef = ref();
const formData = ref({
  username: "",
});
const rules = ref({
  username: [{ required: true, message: "请输入用户名", trigger: "blur" }],
  password: [{ required: true, message: "请输入密码", trigger: "blur" }],
  code: [{ required: true, message: "请输入图形验证码", trigger: "blur" }],
});
const handleLogin = () => {
  router.push("/business/home");
  //   ruleFormRef.value.validate((valid) => {
  //     if (valid) {
  //       console.log(formData.value);
  //     } else {
  //       console.log("error submit!!");
  //     }
  //   });
};
</script>

<style scoped lang="scss">
.login-container {
  background-image: url("@/assets/images/login/sld_login_bg.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;

  .login-right {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: end;
    padding: 0 5rem;
  }
  .right_bg {
    width: 460px;
    height: 480px;
    overflow: hidden;
    box-shadow: 0 0 10px #dadada91;
    padding: 20px 10px 10px;
    background-color: #fff;
    border-radius: 12px;
    padding: 50px 60px;
  }
  .login_title {
    width: 100%;
    display: flex;
    flex-direction: row;
    align-items: center;
    color: var(--primary-color);
    font-family: MicrosoftYaHei-Bold;
    font-size: 30px;
    font-weight: 700;
    letter-spacing: 2px;
    span {
      color: var(--themeFontDesc);
      font-weight: 400;
    }
  }

  .login_input {
    height: 48px;
    :deep(.el-input__wrapper) {
      // border-radius: 24px;
    }
  }
  .login_code {
    height: 40px;
    width: 96px;
  }
}
</style>
